package com.bjc.controller;

import com.alibaba.fastjson.JSON;
import com.bjc.domain.Product;
import com.bjc.service.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: spring-cloud-alibaba
 * @description:
 * @author: bjc
 * @create: 2021-07-28 22:00
 */
@RestController
@Slf4j
public class ProductController {

    @Autowired
    private ProductService productService;
    @GetMapping("/product/{pid}")
    public Product product(@PathVariable("pid") Integer pid) {
        Product product = productService.findByPid(pid);
        log.info("查询到商品:" + JSON.toJSONString(product));
        return product;
    }

    @RequestMapping("/product/api1/demo1")
    public String demo1(){
        return "demo";
    }

    @RequestMapping("/product/api1/demo2")
    public String demo2(){
        return "demo";
    }

    @RequestMapping("/product/api2/demo1")
    public String demo3(){
        return "demo";
    }

    @RequestMapping("/product/api2/demo2")
    public String demo4(){
        return "demo";
    }
}
